package com.leo.leetcode.s100;

/**
 *
 * @author xuexiaolei
 * @version 2017年11月20日
 */
public class ListNode {
    int val;
    ListNode next;
    ListNode(int x) { val = x; }

    public static ListNode gen(int[] a){
        ListNode head = new ListNode(0);
        ListNode current = head;
        for (int i = 0; i < a.length; i++) {
            current.next = new ListNode(a[i]);
            current = current.next;
        }
        return head.next;
    }

    public static void print(ListNode node){
        while (node != null){
            System.out.print(node.val+" ");
            node = node.next;
        }
        System.out.println();
    }
}
